package test_unitaire;

import static org.junit.Assert.assertTrue;

import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;

import org.junit.Test;

import buisness_service.Depense;
import buisness_service.PosteDepense;
import buisness_service.Rapport;
import buisness_service.User;

public class Test_PosteDepense {

	@Test
	public void testPosteDepenseString() {
		PosteDepense logement = new PosteDepense("logement");

		assertTrue(logement.getId_Poste_Depens() == logement
				.getnbPosteDepense());
		assertTrue(logement.getId() == Rapport.nbCategories);
		
		Rapport.postesDpenses.clear();
		Rapport.postesRevenus.clear();
	}

	@Test
	public void testPosteDepenseStringListOfDepense() {
		Calendar d = Calendar.getInstance();
		d.set(2009, Calendar.DECEMBER, 12);
		User u = new User();
		Depense dep = new Depense(20, d, u);
		Depense dep2 = new Depense(40, d, u);
		List<Depense> listDepense = new ArrayList<Depense>();
		listDepense.add(dep2);
		listDepense.add(dep);
		PosteDepense logement = new PosteDepense("logement", listDepense);
		assertTrue(logement.getId_Poste_Depens() == logement
				.getnbPosteDepense());
		assertTrue(logement.getId() ==  Rapport.nbCategories);

		assertTrue(logement.getDepenses().get(0) == dep2);

		assertTrue(logement.getDepenses().get(0).getPosteDepense() == logement);
		
		Rapport.postesDpenses.clear();
		Rapport.postesRevenus.clear();
	}

}
